<?php 
include_once(dirname(__FILE__)."/conn.php");
$id=isset($_GET["id"])?$_GET["id"]:0;
$dopost=isset($_POST["dopost"])?$_POST["dopost"]:"";

$userClass = new user_user();
if ($dopost=="save"){
	$id=$_POST["id"];
	$userClass->openID = $id;
	$userInfo = $userClass->getUserInfo($id);
	$userInfo["goldnum"] = $_POST["goldnum"];
	$userInfo["diamondnum"] = $_POST["diamondnum"];
	$userInfo["scorenum"] = $_POST["scorenum"];
	$userInfo["lifereserve"] = $_POST["lifereserve"];
	$userClass->saveUserProfile($userInfo);
	
	ShowMsg("修改成功！","user_list.php");
	exit();
}

$userClass->openID = $id;
$userInfo = $userClass->getUserProfile();
// print_r($userInfo);
?>
<script language='javascript'>
function SeePic(img,f){
   if ( f.value != "" ) { img.src = f.value; }
}
</script>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>编辑用户</title>
<link href='base.css' rel='stylesheet' type='text/css'>
</head>
<style>
.npvar { width:90% }
</style>
<body topmargin="8">
<form name="form1" action="" method="post">
  <input type="hidden" name="dopost" value="save">
  <input type="hidden" name="id" value="<?php echo $id;?>">
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td width="4%" height="30"><IMG height=14 src="img/book1.gif" width=20> &nbsp;</td>
      <td width="85%"><a href="user_list.php"><u>用户列表</u></a>&gt;&gt;编辑用户</td>
      <td width="10%">&nbsp; </td>
      <td width="1%">&nbsp;</td>
    </tr>
  </table>
  <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr><td height="2"></td></tr>
</table>
  <table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;openID：</td>
            <td width="250"> <?php echo $userInfo["openid"]?></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;用户昵称：</td>
            <td width="250"> <?php echo $userInfo["nickname"]?></td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;当前生命数：</td>
            <td width="250"> <input name="lifereserve" type="text" id="lifereserve" value="<?php echo $userInfo["lifereserve"]?>" style="width:230">            </td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;当前金币数：</td>
            <td width="250"> <input name="goldnum" type="text" id="goldnum" value="<?php echo $userInfo["goldnum"]?>" style="width:230">            </td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;当前总钻石数：</td>
            <td width="250"> <input name="diamondnum" type="text" id="diamondnum" value="<?php echo $userInfo["diamondnum"]?>" style="width:230">            </td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td height="24" colspan="2" class="bline"> <table width="340" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="90">&nbsp;当前总积分：</td>
            <td width="250"> <input name="scorenum" type="text" id="scorenum" value="<?php echo $userInfo["scorenum"]?>" style="width:230">            </td>
          </tr>
        </table></td>
    </tr>
  </table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="56">
	<table width="100%" border="0" cellspacing="1" cellpadding="1">
        <tr> 
          <td width="17%">&nbsp;</td>
          <td width="83%"><table width="214" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="115"><input name="imageField" type="image" src="img/button_ok.gif" width="60" height="22" border="0"></td>
                <td width="99">
                	<img src="img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:hand">
                </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
</body>
</html>